<#assign base=request.contextPath />
<#assign leafLabel="合同收款">
<!DOCTYPE html>
<html lang="en">
<head>
	<link rel="stylesheet" href="${base}/static/assets/css/chosen.css" />
	<#include "/commons/headImport.ftl">
</head>
<body>
	<div class="main-container" id="main-container">
	<input type="hidden" value="${base}" id="context_hidden_id"/>
		<script type="text/javascript">
			try{ace.settings.check('main-container' , 'fixed')}catch(e){}
		</script>

		<div class="main-container-inner">
			<div class="main-content">
				<div class="page-content">
					<form class="form-horizontal" name="formName" method="post">
					<input type="hidden" value="${receivablesDO.contractId!0}" name="contractId" id="contractId"/>
					<input type="hidden" value="${receivablesDO.id!0}" name="receivablesId" id="receivablesId"/>
					
					<div class="row">
						<div class="col-xs-12">
							
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right"></label>
								<div class="col-sm-3">
									<div class="help-block col-xs-12 col-sm-reset inline">第 ${receivablesDO.periods} 期</div>
								</div>
							</div>
							<div class="space-4"></div>
							
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">未收金额</label>
								<div class="col-sm-3">
									<div class="help-block col-xs-12 col-sm-reset inline">
										${(((receivablesDO.totalAmount-receivablesDO.receivedAmount)/100.0)?string.currency)!0.0}
									</div>
								</div>
							</div>
							<div class="space-4"></div>
							
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">收款日期</label>
								<div class="col-sm-4">
									<div class="row">
	                                    <div class="col-xs-12">
	                                        <div class="input-group input-group-sm">
	                                            <input type="text" id="receivablesDate" readonly="true" class="form-control date-picker" 
	                                            	data-date-format="yyyy-mm-dd"/>
	                                            <span class="input-group-addon"><i class="icon-calendar"></i></span>
	                                        </div>
	                                    </div>
	                            	</div>

								</div>
							</div>
							<div class="space-4"></div>
								
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">收款人</label>
								<div class="col-sm-4">
									<@spring.formInput "receivablesDetailDO.fullName" "class='col-sm-12'"/>
								</div>
							</div>
							<div class="space-4"></div>
								
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">收款方式</label>
								<div class="col-sm-4">
									<@spring.formSingleSelect "receivablesDetailDO.methodCode" payMap 'class="col-sm-10 chosen-select"'/>
								</div>
							</div>
							<div class="space-4"></div>
								
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">收款金额</label>
								<div class="col-sm-3">
									<@spring.formInput "receivablesDetailDO.pageAmount" "class='col-sm-6'"/>
								</div>
							</div>
							<div class="space-4"></div>
						</div><!-- /.col -->
					</div><!-- /.row -->
					</form>
					
					<div class="hr hr32 hr-dotted"></div>
					
					<div class="clearfix">
						<label class="col-sm-2 control-label no-padding-right"></label>
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-xs btn-info" type="button" id="add_id"
								url="${base}/receivablesDetail/add">
								<i class="icon-save bigger-110"></i>保存
							</button>
							<button class="btn btn-xs" type="reset" id="return_id">
								<i class="icon-reply bigger-110"></i>关闭
							</button>
						</div>
					</div>
					
				</div><!-- /.page-content -->
			</div><!-- /.main-content -->
		</div><!-- /.main-container-inner -->
	</div><!-- /.main-container -->
<#include "/commons/footJs.ftl">
<script src="${base}/static/assets/js/date-time/bootstrap-datepicker.min.js"></script>
<script src="${base}/static/assets/js/date-time/bootstrap-datepicker.zh-CN.js"></script>
<script src="${base}/static/layer/layer.js"></script>
<script src="${base}/static/assets/js/chosen.jquery.min.js"></script>
<script type="text/javascript">
	jQuery(function($) {
		$(".chosen-select").chosen();
		
		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	
	   	$("#add_id").click(function(){
	   		var url=$(this).attr("url");
			var contractId=$("#contractId").val();
			var receivablesId=$("#receivablesId").val();
	   		var receivablesDate= $("#receivablesDate").val();
	   		var fullName = $("#fullName").val();
	   		var methodCode=$("#methodCode option:selected").val();
	   		var pageAmount = $("#pageAmount").val();
	   		if(receivablesDate==""){
	   			layer.msg('收款日期必须填写');
	   			return false;
	   		}
	   		if(fullName==""){
	   			layer.msg('收款人必须填写');
	   			return false;
	   		}
	   		if(methodCode==""){
	   			layer.msg('收款方式必须填写');
	   			return false;
	   		}
	   		if(pageAmount==""||pageAmount<=0){
	   			layer.msg('收款金额必须大于0');
	   			return false;
	   		}
	   		layer.load(2);
			$.ajax({
				type:"POST",
				url:url,
				dataType:"json",
				data:{
					"contractId": contractId,
					"receivablesId": receivablesId,
					"receivablesDate": receivablesDate,
					"fullName":fullName,
					"methodCode":methodCode,
					"pageAmount":pageAmount
					},
			  	success:function(data){
				     if(data.success){
				     	layer.closeAll('loading');
				     	parent.layer.close(index);
				     	window.parent.location.reload();
				     }else{
				     	var json = JSON.stringify(data.msg);
				     	layer.msg(json);
				     	layer.closeAll('loading');
				     }
				 },
				 error:function(msg){
			     	var json = JSON.stringify(msg);
			     	layer.msg(json);
			     	layer.closeAll('loading');				 
				 }
			});
	   	});
	   	
	   $("#return_id").click(function(){
			parent.layer.close(index);
	   });
	   
	   $('.date-picker').datepicker({
	   		language: 'zh-CN',//选择语言
			autoclose: true,
			todayHighlight: true
		});
	});
</script>
</body>
</html>
